local sk__guagu = fk.CreateSkill {

  name = "sk__guagu",

  tags = {  },

}



sk__guagu:addEffect(fk.EnterDying, {
  name = "sk__guagu",
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__guagu.name) and not target:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, sk__guagu.name, data, "#sk__guagu-invoke::"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    local n = #table.filter(target:getCardIds("h"), function (id)
      return not target:prohibitDiscard(id)
    end)
    target:throwAllCards("h")
    if target.dead then return end
    if target.hp < 1 then
      room:recover{
        who = target,
        num = 1 - target.hp,
        recoverBy = player,
        skillName = sk__guagu.name,
      }
    end
    if not target.dead and n > 1 then
      target:drawCards(1, sk__guagu.name)
    end
  end,
})

return sk__guagu